package com.example.thirdstage_project.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.thirdstage_project.entity.Project;
import com.example.thirdstage_project.entity.ProjectCategory;
import com.example.thirdstage_project.ov.ProjectCategoryExpertOV;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author 86158
 * @version 1.0
 * Create by 2022/11/28 20:42
 */

@Mapper
public interface ProjectCategoryDao extends BaseMapper<ProjectCategory> {

    @Select(" select categoryid,categoryname,rep_start_time,rep_stop_time,name from  project_category,expert WHERE project_category.expertid=expert.expertid")
    List<ProjectCategoryExpertOV> select();


    @Results({
            @Result(column="rep_start_time",property="rep_start_time",jdbcType=JdbcType.TIMESTAMP),
            @Result(column="rep_stop_time",property="rep_stop_time",jdbcType= JdbcType.TIMESTAMP)
    })
    @Select("select categoryid,categoryname,rep_start_time,rep_stop_time from project_category ")
    List<ProjectCategoryExpertOV> selectfour();

    @Select("select projectname,unitname,applicant,grade,education," +
            "fill_date,status,future,analysis,way,result," +
            "capital,expert_opinion,score from project ,expert where categoryid=#{categoryid}")
    List<ProjectCategory> selectByPid(int categoryid);

    @Update("update project set projectname =#{projectname}," +
            "unitname=#{unitname}," +
            "applicant=#{applicant},grade=#{grade},education=#{education}" +
            ",fill_date=#{fill_date},status=#{status},future=#{future}," +
            "analysis=#{analysis},way=#{way}," +
            "result=#{result},capital=#{capital},expert_opinion=#{expert_opinion}" +
            ",score=#{score} " +
            "where project_id={project_id} ")
    int updateProject(Project project);

    @Update("update set categoryid=#{categoryid},categoryname=#{categoryname},rep_start_time=#{rep_start_time}," +
            "rep_stop_time=#{rep_stop_time} where categoryid=#{categoryid}")
    int updatePro(ProjectCategory projectCategory);
}
